<?php
if(isset($_GET['table']) && isset($_POST['hid_order'])){	
require_once("../../libraryfiles/config.php");
	$sp_order 	= split(' ',$_POST['hid_order']);
	
	$len = sizeof($sp_order);
	
	for($i=0; $i<$len; $i++){
		$ordering++;
		$sql = "UPDATE $_GET[table] 
				SET ordering= $ordering 
				WHERE id=$sp_order[$i]";
		mysql_query($sql);
	}
	
	$sql = "ALTER TABLE $_GET[table] 
			ORDER BY ordering";

	mysql_query($sql);
	
	if($i == $len){
	?>
    <script>alert("Completed");</script>
    <?php
	}
	else{
	?>
    <script>alert("Incompleted");</script>
    <?php	
	}
	
}
?>